package com.example.littleSpider.myapplication.fragment.gankuai.recivesure;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.example.littleSpider.myapplication.R;
import com.example.littleSpider.myapplication.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by EDZ on 2017/12/22.
 * 网点收发货确认 到货确认
 */

public class AcceptConfirmFragment extends BaseFragment {

    @BindView(R.id.acceptconfirm_tabs)
    TabLayout acceptconfirm_tabs;
    @BindView(R.id.acceptconfirm_vp)
    ViewPager acceptconfirm_vp;

    FragmentManager manager;
    List<Fragment> fragmentList = new ArrayList<>();

    AcceptDispatchFragment dispatchFragment = new AcceptDispatchFragment();
    AcceptTobeevaluatedFragment tobeevaluatedFragment = new AcceptTobeevaluatedFragment();
    AcceptCompletedFragment completedFragment = new AcceptCompletedFragment();
    AcceptAllFragment allFragment = new AcceptAllFragment();
    @Override
    protected int setLayout() {
        return R.layout.fragment_acceptconfirm;
    }

    @Override
    protected void initView() {
        manager = getActivity().getSupportFragmentManager();

        fragmentList.add(dispatchFragment);
        fragmentList.add(tobeevaluatedFragment);
        fragmentList.add(completedFragment);
        fragmentList.add(allFragment);

        acceptconfirm_tabs.setupWithViewPager(acceptconfirm_vp);
        acceptconfirm_vp.setAdapter(new MyPageAdapter(manager));
    }

    @Override
    protected void initData() {

    }

    class MyAdapter extends PagerAdapter {

        @Override
        public int getCount() {
            return 4;
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {

            return false;
        }


    }

    class MyPageAdapter extends FragmentPagerAdapter {

        FragmentManager manager;

        public MyPageAdapter(FragmentManager fm) {
            super(fm);
            manager = fm;
        }

        @Override
        public Fragment getItem(int position) {
            return fragmentList.get(position);
        }

        @Override
        public int getCount() {
            return fragmentList.size();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            if (position == 0){
                return "派送中";
            }
            if (position == 1){
                return "待评价";
            }
            if (position == 2){
                return "已完成";
            }

            if (position == 3){
                return "全部";
            }

            return null;
        }

    }
}
